import java.util.Scanner;

public class Test {
    public static int sum1(int n) {//返回输入的非负整数的每一位之和
        if (n<10){
            return n;
        }
        int sum = 0;
        sum =sum1(n/10) + n%10;
        return sum;
    }

    public static void main(String[] args) {
        int a = sum1(123456789);
        System.out.println(a);
    }
    public static void printt(int n) {//使用递归的方法依次打印数字的每一位
        if (n <= 9){
            System.out.println(n);
            return;
        }
        printt(n/10);
        System.out.println(n%10);
    }

    public static void main3(String[] args) {
        printt(1234);
    }
    public static int sum(int n) {//使用递归计算1到10的和
        if (n==1){
            return 1;
        }
        int sum = n+sum(n-1);
        return sum;
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        System.out.println(sum(a));
        scanner.close();
    }
    public static int jiecheng(int n) {//使用递归的方法计算输入N的阶乘
        if (n==1){
            return 1;
        }
        int ret = n*jiecheng(n-1);
        return ret;
    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = jiecheng(n);
        System.out.println(a);
    }
}
